#include <fstream>
#include <iostream>
#include "spdlog/spdlog.h"
#include "gtest/gtest.h"
#include "nlohmann/json.hpp"
#include "scan.h"


TEST(ScanTest, parserVideoInfo) {
    std::ofstream outfile("videoInfo.json");
    nlohmann::json jsonData = nlohmann::json::parse(R"({"groupTitle": "STM32开发", "title": "介绍", "p": 1, "itemId" : 26771914762})");
    outfile << jsonData.dump(4);
    outfile.close();

    const std::shared_ptr<VideoInfo> vidoInfo = scan::parserVideoInfo(std::filesystem::path("./"));
    EXPECT_NE(nullptr, vidoInfo);
    EXPECT_EQ(vidoInfo->title, jsonData["title"].get<std::string>());
    EXPECT_EQ(vidoInfo->groupTitle, jsonData["groupTitle"].get<std::string>());
    EXPECT_EQ(vidoInfo->number, jsonData["p"].get<qint32>());
    EXPECT_EQ(vidoInfo->itemId, jsonData["itemId"].get<qint64>());

}